package com.hdu.clj.fitness

import android.app.Activity
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageView
import android.widget.TextView

class AchAdapter(activity: Activity,val resourceId:Int,data:List<Ach>):ArrayAdapter<Ach>(activity,resourceId,data) {
    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        val view= LayoutInflater.from(context).inflate(resourceId,parent,false)
        val achImage:ImageView=view.findViewById(R.id.imageAch)
        val achName:TextView=view.findViewById(R.id.nameAch)
        val ach= getItem(position)
        if (ach!=null){
            achImage.setImageResource(ach.imageId)
            achName.text = ach.name
            achName.textSize = ach.size.toFloat()
            achName.setTextColor(Color.parseColor(ach.color))
        }
        return view
    }
}